#include "widget.h"
#include "ui_widget.h"
#include<QIcon>
#include<QDir>
#include<QString>
#include<string>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    this->setWindowOpacity(1);
    QIcon icon(":/dog.png");
    this->setWindowTitle("宠物狗");
    this->setWindowIcon(icon);
    //QString currentDir=QDir::currentPath();
    //ui->labelDir->setText(currentDir);
}

Widget::~Widget()
{
    delete ui;
}


void Widget::on_pushButton_on_clicked()
{
    float Opacity=this->windowOpacity();
    if(Opacity>=1){
        return;
    }
    Opacity+=0.1;
    this->setWindowOpacity(Opacity);
    std::string str=std::to_string(Opacity);
    QString s="透明度为"+QString::fromStdString(str);
    ui->label->setText(s);
}

void Widget::on_pushButton_off_clicked()
{
    float Opacity=this->windowOpacity();
    if(Opacity<=0){
        return;
    }
    Opacity-=0.1;
    this->setWindowOpacity(Opacity);
    std::string str=std::to_string(Opacity);
    QString s="透明度为"+QString::fromStdString(str);
     ui->label->setText(s);
}
